package com.javasm.springmybatis.task;

import com.javasm.springmybatis.async.AsyncFactory;
import com.javasm.springmybatis.async.AsyncManager;
import com.javasm.springmybatis.entity.Admin;
import com.javasm.springmybatis.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author：xieyunfan
 * @Version：1.0
 * @Date：2022/1/1-0:28
 * @Since:jdk1.8
 * @Description:
 */
//发送邮件定时
@Component
public class SendEmailTask {


    @Autowired
    private IAdminService iAdminService;

    @Scheduled(cron = "0/10 * * * * *")
    public void sendMail() {
        List<Admin> list = iAdminService.list();
        for (Admin admin : list) {
            AsyncManager.getInstance().execute(AsyncFactory.sendEmail(admin.getEmail(),"popo"));
        }


    }

}
